package com.github.baichuan.binary;

/**
 * 校验和
 */
public enum CheckSum {
    /**
     * BCC校验(异或校验)
     */
    BBC {
        @Override
        public byte[] check(byte[] bytes, int start, int length){
            byte b = bytes[start];
            for(int i = 1; i < length; i++){
                b ^= bytes[start + i];
            }
            return new byte[] { b };
        }
    };

    public abstract byte[] check(byte[] bytes, int start, int length);
}